<?php
 session_start();
require_once("bdd.php"); 

if( isset($_GET['rep']) && isset($_GET['id']) && isset($_GET['nb']) ) {


	//echo "rep= " . $_GET['rep'] . " id=". $_GET['id'];
	
	if($_GET['rep'] == 1) {
	
		
	    $tmp = $_GET['nb'] + 1;
		$connexion->exec("UPDATE reponse SET nbA=".$tmp." WHERE idreponse=".$_GET['id']."");echo $_GET['nb'] . " ". $_GET['rep'];
	}
	else if ($_GET['rep'] == 2) {
	
		$tmp = $_GET['nb'] + 1;
		$connexion->exec("UPDATE reponse SET nbB=".$tmp." WHERE idreponse=".$_GET['id']."");echo $_GET['nb'] . " ". $_GET['rep'];
	}
	else if ($_GET['rep'] == 3) {
		$tmp = $_GET['nb']+1;
		$connexion->exec("UPDATE reponse SET nbC=".$tmp." WHERE idreponse=".$_GET['id']."");
		//echo $_GET['nb'] . " ". $_GET['rep'];
	}
	else if ($_GET['rep'] == 4) {
		$tmp = $_GET['nb']+1;
		$connexion->exec("UPDATE reponse SET nbD=".$tmp." WHERE idreponse=".$_GET['id']."");echo $_GET['nb'] . " ". $_GET['rep'];
	}
	
	
		$adresse = $_SERVER['REMOTE_ADDR'];
		$connexion->query("INSERT into ip(ip,idsondage) values('".$adresse."',".$_GET['id'].")");
	
} 
?>